package gl.java.sms;

import java.io.File;
import java.io.IOException;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class Applictation implements Servlet {
	boolean taskFlag = true;
	/* 服务器本地路径 */public static String path_file = "e:\\\\hao123\\";
	/* 服务器本地路径 */public static String path_temp_dir_name = "temp";
	@Override
	public void destroy() {
		taskFlag = false;
	}

	@Override
	public ServletConfig getServletConfig() {
		return null;
	}

	@Override
	public String getServletInfo() {
		return null;
	}

	@Override
	public void init(ServletConfig config) throws ServletException {
		path_file = config.getServletContext().getRealPath(File.separator)+path_temp_dir_name+File.separator;
		File file =new File(path_file);
		if (!file.exists()) {
			if(!file.mkdirs()){
				path_file = config.getServletContext().getRealPath(File.separator);	
			}
		}
		System.out.println("path_file:" + path_file);
		new Thread() {
			public void run() {
				while (taskFlag) {
					try {
						SMS.taskLoop();
						Thread.sleep(10*1000);
					} catch (Exception e) {
					}

				}
			};
		}.start();
	}

	@Override
	public void service(ServletRequest req, ServletResponse res)
			throws ServletException, IOException {

	}

}
